<!--
 * @Author: zheng yong tao
 * @Date: 2022-01-15 15:23:41
 * @LastEditors: zheng yong tao
 * @LastEditTime: 2022-03-06 11:26:59
 * @Description: 
-->
<template>
  <div id="app">
    <top class="top-menu"></top>

    <router-view class="router-view" />
  </div>
</template>

<script>
import top from "@/components/menu/top.vue";
import loginPanel from "@/components/loginPanel.vue";
import { getToday } from "./util/dateTool";
import { visit } from "./config/api";
import { myHttp } from "./config/http";
import { setBgImg } from "./assets/js/init";
import Vue from "vue";
export default {
  name: "App",
  components: {
    top,
    loginPanel
  },
  data() {
    return {};
  },
  mounted() {
    this.initData();
  },
  created() {
    this.initPage();
  },
  beforeDestroy() {
    localStorage.removeItem("JPage");
  },
  methods: {
    initPage() {
      this.initHttp();
      //this.getIp();
      setBgImg();
    },
    initHttp() {
      let http = new myHttp(this);
      Vue.prototype.myHttp = http;
      Vue.prototype.httpGet = http.httpGet;
      Vue.prototype.httpPost = http.httpPost;
    },
    getIp() {
      let postData = {
        cid: returnCitySN["cid"],
        cname: returnCitySN["cname"],
        ip: returnCitySN["cip"],
        time: getToday("yyyy-mm-dd hh:MM:ss")
      };
      const lastDateTime = parseInt(localStorage.getItem("jLastDateTime"));
      if (lastDateTime != undefined) {
        const nowDateTime = new Date().getTime();
        if ((nowDateTime - lastDateTime) / 1000 < 3600) return;
      }
      localStorage.setItem("jLastDateTime", new Date().getTime());
      this.httpPost(visit, postData);
    },
    initData() {
      localStorage.setItem("JPage", 1);
    }
  }
};
</script>

<style lang="scss">
body {
  margin: 0;
  padding: 0;
}
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  //background-color: rgb(229, 226, 226);
  // min-height: 100vh;
  padding-top: 60px;
  z-index: 1;
  opacity: 0.8;
  width: 100vw;
}
.top-menu {
  position: fixed;
  top: 0;
  width: 100%;
  height: 60px;
  z-index: 1;
}
.router-view {
  z-index: 1;
  min-height: calc(100vh - 60px);
}
.login-panel {
  line-height: 2rem;
  padding: 1rem;
  .login-panel-item {
    margin-top: 1rem;
    input {
      height: 2rem;
    }
  }
}
</style>
